Beacon Time Series, across the transition

Edit selector= below

Look at the beacons with the largest normalized spread.


In [1]:
import math
import pandas as pd
import BQhelper as bq
import matplotlib.pyplot as plt

bq.project = "mlab-sandbox"
# bq.dataset = 'mattmathis'
# bq.UnitTestRunQuery()
# bq.UnitTestWriteQuery()

In [2]:
query="""
SELECT
  a.TestTime,
  client.IP,
  a.MeanThroughputMbps,
  node._instruments
# FROM   `mlab-sandbox.mm_unified_testing.unified_downloads`
FROM `measurement-lab.ndt.unified_downloads`
WHERE client.IP in ( {clientIP} )
AND test_date > '2019-03-01'
ORDER BY TestTime

"""

In [3]:
%matplotlib nbagg
# from matplotlib import interactive
# interactive(True)
plt.ion()

clients = [
    '69.68.23.44', # Max deltaMean
    '96.229.66.58' # Max deltaMax
]


def plotMultiBeacons(clients, columns=1, width=10, data=None, selector='downloads'):
    if data is None:
        clist = '"'+'", "'.join(clients)+'"'
        data=bq.QueryTimestampTimeseries(query, clientIP=clist, selector=selector)
        global StashData # Skip slow queries when debugging
        StashData = data
    rows = math.ceil(len(clients) / float(columns))
    figLen = width/float(columns)*rows  # assume square subplots
    print('Size', figLen, width)
    plt.rcParams['figure.figsize'] = [ width, figLen]
    
    fig, axs = plt.subplots(nrows=rows, ncols=columns, squeeze=False, sharex='all')
    for ax, client in zip([i for j in axs for i in j], clients):
        print ('Beacon: '+client)
        ax.set_title('Beacon: '+client)
        cdata = data[data['IP'] == client]
        ax.plot(cdata['MeanThroughputMbps'][cdata["_instruments"] == 'web100'], 'b.',
            cdata['MeanThroughputMbps'][cdata["_instruments"] == 'tcpinfo'], 'r.')
    fig.autofmt_xdate()
    fig.show()
    
    
# plotMultiBeacons(clients, 2, width=10)

In [4]:
# NB: ThousandRandomBeacons4perDay are all domotz tests, which are unspeakably ugly.

listq="""
With

Beacons AS (
SELECT
  clientIP,
  node._Instruments AS vers,
  count(*) AS tests,
  MIN(a.MeanThroughputMbps) AS minTput,
  SUM(a.MeanThroughputMbps) /Count(*) AS meanTput,
  STDDEV(a.MeanThroughputMbps) /Count(*) AS stddevTput,
  MAX(a.MeanThroughputMbps) AS maxTput,
  MIN(a.MinRTT ) AS minMinRTT,
  SUM(a.MinRTT ) /Count(*) AS meanMinRTT,
  MAX(a.MinRTT ) AS maxMinRTT
FROM
  `measurement-lab.ndt.unified_downloads`   -- Remember to test both uploads and downloads
  JOIN `mlab-sandbox.mattmathis.ThousandRandomBeacons4perDay` ON Client.IP = clientIP
WHERE
  test_date BETWEEN '2019-03-01' AND '2020-03-01'
GROUP BY
  node._Instruments, clientIP
),

Paired AS (
SELECT
  NDT5.meanTput - NDTlegacy.meanTput AS delta,
  NDT5.maxTput - NDTlegacy.maxTput AS deltaMax,
  ABS(NDT5.meanTput - NDTlegacy.meanTput ) / SQRT(NDT5.stddevTput*NDTlegacy.stddevTput) AS spread,
  NDT5,
  NDTlegacy,
FROM ( SELECT * FROM Beacons WHERE vers = 'tcpinfo' ) AS NDT5
JOIN ( SELECT * FROM Beacons WHERE vers = 'web100' ) AS NDTlegacy USING ( clientIP )
)

# Choose
SELECT * FROM Paired ORDER BY {selector} LIMIT 30
"""

In [5]:
selector="delta desc"
selector="deltaMax desc"
stepbeacons=bq.DataFrameQuery(listq, selector=selector)

In [6]:
# lame
beacons = []
for t in stepbeacons['NDT5']:
    beacons.append(t['clientIP'])
plotMultiBeacons(beacons, 2, width=10)


Size 75.0 10
Beacon: 96.229.66.58
Beacon: 71.43.189.138
Beacon: 88.98.250.242
Beacon: 172.249.73.209
Beacon: 217.61.218.114
Beacon: 172.3.47.50
Beacon: 107.211.229.138
Beacon: 83.48.89.20
Beacon: 99.97.29.175
Beacon: 77.161.61.222
Beacon: 130.180.108.206
Beacon: 63.203.5.165
Beacon: 82.33.150.82
Beacon: 87.244.76.183
Beacon: 68.89.236.195
Beacon: 145.255.60.135
Beacon: 71.226.238.225
Beacon: 74.95.100.226
Beacon: 76.91.11.126
Beacon: 74.62.208.125
Beacon: 67.161.83.114
Beacon: 64.183.100.155
Beacon: 172.88.195.234
Beacon: 104.190.166.9
Beacon: 67.14.224.119
Beacon: 104.7.217.223
Beacon: 76.79.240.170
Beacon: 76.218.39.83
Beacon: 68.99.248.122
Beacon: 73.155.103.44

In [7]:
# Particularly ugly, 
# plotMultiBeacons(['67.161.83.114'], 1, width=10)